package org.triumphxx.springboot.async.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.io.BufferedWriter;
import java.io.FileWriter;

/**
 * @author:triumphxx
 * @Date: 2023/12/9
 * @Time: 17:18
 * @微信公众号：思考集结处
 * @网站：http://blog.triumphxx.com.cn
 * @GitHub https://github.com/triumphxx
 * @Desc: 测试Async
 **/

@Service
@Slf4j
public class AsyncErrService {

    @Async
    public String async(){
        log.info("开始处理异步任务，线程号为：{}", Thread.currentThread().getName());
        try {
                Thread.sleep(100);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        log.info("结束处理异步任务，线程号为：{}", Thread.currentThread().getName());
        return  Thread.currentThread().getName()+": 执行完成";
    }
}
